#ifndef GEARCONTROL_H
#define GEARCONTROL_H

#include <QGraphicsObject>
#include <QPainter>
#include <QGraphicsSceneMouseEvent>

class GearControl : public QGraphicsObject
{
    Q_OBJECT

public:
    explicit GearControl(QGraphicsItem *parent = nullptr);

    // 必须实现的纯虚函数
    QRectF boundingRect() const override;
    void paint(QPainter *painter,
               const QStyleOptionGraphicsItem *option,
               QWidget *widget = nullptr) override;

signals:
    void gearCommand(int command);  // 档位命令信号

protected:
    void mousePressEvent(QGraphicsSceneMouseEvent *event) override;

private:
    enum KeyValue{up,down,left,right,park,stop,leftup,rightup,leftdown,rightdown,none}; //park能左右转，stop是完全静止
    void handleButtonClick(const QPointF &pos);
};

#endif // GEARCONTROL_H
